package com.smarthospital.web.configuration;

import com.fasterxml.classmate.TypeResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

    @Autowired
    private TypeResolver typeResolver;
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/")
//                .additionalModels(typeResolver.resolve(Doctor.class))
//                .additionalModels(typeResolver.resolve(InquiryOrder.class))
//                .additionalModels(typeResolver.resolve(User.class))
//                .additionalModels(typeResolver.resolve(DoctorDuty.class))
//                .additionalModels(typeResolver.resolve(DutiesDTO.class))
//                .additionalModels(typeResolver.resolve(SHDictionary.class))
//                .additionalModels(typeResolver.resolve(IMMessage.class))
//                .additionalModels(typeResolver.resolve(WXPrePayVO.class))
//                .additionalModels(typeResolver.resolve(WXGoodsDetailVO.class))
//                .additionalModels(typeResolver.resolve(WXAmountVO.class))
//                .additionalModels(typeResolver.resolve(PrePayResultDTO.class))
//                .additionalModels(typeResolver.resolve(PrePayOderDTO.class))
//                .additionalModels(typeResolver.resolve(LoginResultDTO.class))
//                .additionalModels(typeResolver.resolve(SocketDTO.class))
//                .additionalModels(typeResolver.resolve(WxAuthInfoVO.class))
//                .additionalModels(typeResolver.resolve(Report.class))
                ;
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("智慧医院app接口文档")
                .description("【notes】\n" +
                             "【token】登录以后接口请求头中带token SH_TOKEN\n" +
                             "【重新登陆】 code = 10401\n"
                            )
                .version("version 1.0.0")
                .build();
    }

}
